package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.bean.WorkLogBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BasePageListBean;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IWorkLogView;

import java.util.Map;

/**工作日志
 * Created by admin on 2017/12/6.
 */

public class WorkLogPest {
    private IWorkLogView iWorkLogView;

    public WorkLogPest( IWorkLogView iWorkLogView) {
        this.iWorkLogView=iWorkLogView;
    }

    public void getWorkLogList(Context context, int page, int rows,String orgId,
                               String searchTitle, String workUser,
                               String workTimeStart,String workTimeEnd){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("page", page);
        map.put("rows", rows);
        map.put("workDiaryVo.orgId",orgId);
        map.put("workDiaryVo.title",searchTitle);
        map.put("workDiaryVo.workUser",workUser);
        map.put("workDiaryVo.workTimeStart",workTimeStart);
        map.put("workDiaryVo.workTimeEnd",workTimeEnd);
        new ApiManager().getWorkLogList(map, new BaseCallBack<BaseResult<BasePageListBean<WorkLogBean>>>() {
            @Override
            public void onSuccess(BaseResult<BasePageListBean<WorkLogBean>> response) {
                iWorkLogView.getWorkLogListSuccess(response.getData().permission,response.getData().rows,response.getData().getTotal());
            }
            @Override
            public void onFailures(String message) {
                iWorkLogView.showError(message);
            }
        });
    }

}
